package com.yl.pattern.creatormodel.prototype.demo3;

import java.io.*;

/**
 * @Author 小羊
 * @Date 30/10/2024下午 3:56
 * @ClassName CitationTest
 * @Description 访问测试类
 */
public class CitationTest {
    public static void main(String[] args) throws CloneNotSupportedException, IOException, ClassNotFoundException {
        Citation c1 = new Citation();
        Student student = new Student();
        student.setName("张三");
        c1.setStudent(student);

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("C:\\Users\\Lenovo\\Desktop\\a.txt"));
        oos.writeObject(c1);
        oos.close();
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("C:\\Users\\Lenovo\\Desktop\\a.txt"));
        Citation c2 = (Citation) ois.readObject();

        c2.getStudent().setName("李四");
        c1.show();
        c2.show();

    }
}
